package gaml.java.serializer.primitive;

import gaml.error.GamlException;
import gaml.java.ClassSerializer;
import gaml.yaml.ScalarNode;
import gaml.yaml.YamlNode;
import gaml.yaml.ahchor.YamlAnchorCodeStore;
import gaml.yaml.ahchor.YamlAnchorObjectStore;


/**
 * make a node from string object
 * make a string object from node
 * @author shnireck
 *
 */
public class StringSerializer implements ClassSerializer <String> {
	
	@Override
	public Class <String> getObjectClass () { return String.class; }
	
	@Override
	public boolean noAnchor () { return true; }

	@Override
	public String restore (YamlNode node, String object, YamlAnchorCodeStore anchors) { return node.getValue (); }

	@Override
	public YamlNode serialize (YamlNode node, String obj, YamlAnchorObjectStore anchors) { return new ScalarNode (node.getParent ()).setValue (obj); }

	@Override
	public YamlNode createNode (YamlNode parent) { return new ScalarNode (parent); }

	@Override
	public String createObject () throws GamlException { return null; }
}